﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace WebApplication3
{
    public partial class Modificar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection conexion=new SqlConnection("Data Source=USUARIO-PC\\SQLEXPRESS;Initial Catalog=patiodecomidas;Integrated Security=True;Pooling=False");
            conexion.Open();

            int idpedido = int.Parse(TextBox1.Text);
            SqlCommand comando=new SqlCommand("select * from Pedido where id_pedido="+idpedido,conexion);

            SqlDataReader lector=comando.ExecuteReader();


            if(lector.Read())
            {
                Label1.Text="Pedido encontrado";
                DropDownList1.SelectedIndex=(int)lector["cod_menu"];
                DropDownList2.SelectedIndex=(int)lector["cod_bebidas"];
                DropDownList3.SelectedIndex=(int)lector["cod_postre"];
                TextBox2.Text=lector["descripcion"].ToString();
                //*/*///

            }
            else
               Label1.Text="Pedido no encontrado";

            conexion.Close();

      

     

          //  SqlCommand comando=new SqlCommand("update Pedido set (cod_menu=*/
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            SqlConnection conexion = new SqlConnection("Data Source=USUARIO-PC\\SQLEXPRESS;Initial Catalog=patiodecomidas;Integrated Security=True;Pooling=False");
            conexion.Open();
            int idpedido = int.Parse(TextBox1.Text);
            int cmenu=(int)DropDownList1.SelectedIndex;
            int cpostre=(int)DropDownList2.SelectedIndex;
            int cbebidas=(int)DropDownList3.SelectedIndex;

            SqlCommand comando=new SqlCommand("update Pedido set cod_menu="+cmenu+",cod_bebidas="+cbebidas+",cod_postre="+cpostre+"where id_pedido="+idpedido,conexion);
            if(comando.ExecuteNonQuery()>0)
               Label1.Text="Pedido act con exito";
            else
                Label1.Text="Error";

            conexion.Close();
        }
    }
}